<?php

abstract class template_abstract {

	protected $_object;
	public static $folder;
	
	public function __construct($object){
		$this->_object = $object;
	}
	
	public function __get($var){
		return $this->_object->$var;
	}
	
	public function __call($method, $args){
		$path = str_replace('_','/',$method);
		/**
		 * @todo eval
		 */
		eval('$folder = '.get_class($this).'::$folder');
		$template = $folder.'/'.$path.'/.phtml'; 
		return @include $template;
	}
	
	public function render($file){
		$type = $this->_object->type;
		
		while(!$success = call_user_method($type.'_'.$file,$this)){
			if($type=get_parent_class('object_'.$type)) $type=substr($type,7);
			else break;
		}
	}
	
}